<template>
  <div class="works-details-contaienr" :style="{ width: `${width}px`, height: `${height}px` }">
    <div class="works-figure">
      <div class="works-image">
        <img :src="works.cover.at(-1)" alt="" />
      </div>
      <a
        class="works-figcaption"
        target="_blank"
        :href="`https://www.douyin.com/video/${works.id}`"
        :title="works.title"
      >
        {{ works.title }}
      </a>
    </div>
  </div>
</template>

<script lang="ts">
import type { Works } from 'shared'
import type { PropType } from 'vue'

export default defineComponent({
  name: 'WorksDetails',
  props: {
    width: {
      type: Number,
      default: 150,
    },
    height: {
      type: Number,
      default: 220,
    },
    works: {
      type: Object as PropType<Works>,
      required: true,
    },
    manage: {
      type: Boolean,
      default: false,
    },
  },
  setup(props) {},
})
</script>

<style lang="scss" scoped>
.works-details-contaienr {
  overflow: hidden;

  .works-figure {
    height: 100%;
    display: flex;
    flex-direction: column;
    margin: 0;
    overflow: hidden;
  }

  .works-image {
    flex: 1;
    border-radius: 4px;
    overflow: hidden;

    img {
      width: 100%;
      height: 100%;
      // object-fit: cover;
    }
  }

  .works-figcaption {
    height: 20px;
    line-height: 20px;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
